using System;
using System.Runtime.Serialization;

namespace Widgetsphere.Generator.Common.Exceptions
{
	[Serializable] 
	public class WidgetsphereException : System.ApplicationException
	{
		/// <summary>
		/// 
		/// </summary>
		public string ErrorCode = null;
		public string []Arguments = null;

		/// <summary>
		/// 
		/// </summary>
		public WidgetsphereException (): base ()
		{
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="message"></param>
		public WidgetsphereException ( string Message ) : base ( Message )
		{
		}
		
		/// <summary>
		/// 
		/// </summary>
		/// <param name="message"></param>
		/// <param name="inner"></param>
		public WidgetsphereException ( string Message, System.Exception InnerException ) : base ( Message, InnerException )
		{
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="errorCode"></param>
		/// <param name="message"></param>
		public WidgetsphereException ( string ErrorCode, string Message ) : base ( Message )
		{
			this.ErrorCode = ErrorCode;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="errorCode"></param>
		/// <param name="arguments"></param>
		public WidgetsphereException ( string ErrorCode, params object [] Arguments )
		{
			this.ErrorCode = ErrorCode;
			//this.arguments = arguments;

			this.Arguments = new string [Arguments.Length];

			for ( int length = 0; length < Arguments.Length; ++ length )
			{
				this.Arguments[length] = (string)Arguments [length];
			}

		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="errorCode"></param>
		/// <param name="message"></param>
		/// <param name="inner"></param>
		public WidgetsphereException ( string ErrorCode, string Message, System.Exception InnerException ) : base ( Message, InnerException )
		{
			this.ErrorCode = ErrorCode;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		public WidgetsphereException ( SerializationInfo SerializationInfo, StreamingContext Context ) : base ( SerializationInfo, Context )
		{
			this.ErrorCode = ( string ) SerializationInfo.GetValue ( "errorCode", typeof ( string ) );
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		public override void GetObjectData ( SerializationInfo SerializationInfo, StreamingContext Context )
		{
			SerializationInfo.AddValue ( "errorCode", ErrorCode );
			base.GetObjectData ( SerializationInfo, Context ) ;
		}
	}
}